package com.pe1n.yangtaopai.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.pe1n.yangtaopai.R;
import java.util.List;

/**
 * Created by Pe1n on 2016/11/27.
 */

public class MyImgRecyclerAdapter extends RecyclerView.Adapter<MyImgRecyclerAdapter.MyViewHolder> {

    private Context mContext;
    private List<String> mList;

    public MyImgRecyclerAdapter(Context mContext, List<String> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public MyImgRecyclerAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_detail_bottom_layout,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyImgRecyclerAdapter.MyViewHolder holder, int position) {
        Glide.with(mContext).load(mList.get(position)).placeholder(R.drawable.place_holder).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        private ImageView imageView;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_item_detail_bottom);
        }
    }

}
